/*
 *  $Id: ParticleState.cs 1133 2010-09-29 15:42:17Z thenn.erannor $
 *  This file is a part of Ragima CCG.
 *  (C) 2008-2009 Ragima development group.
 *
 *  Licensed under the terms of the GNU GPL License version 2.
 *
 */

using System;
using System.Collections.Generic;

using AgateLib.Geometry;

namespace Ragima.UI {
    /// <summary>
    /// Состояние частицы: время, цвет, прозрачность, масштаб, угол поворота.
    /// </summary>
    public class ParticleState {
        private int _morphTime, _lifeTime;
        private Color _color;
        private double _alpha, _scale, _angle;
        private IEnumerable<PointF> _trajectory;

        public ParticleState(int morphTime, int lifeTime, Color color, double alpha, double scale, double angle, IEnumerable<PointF> trajectory) {
            _morphTime = morphTime;
            _lifeTime = lifeTime;
            _color = color;
            _alpha = alpha;
            _scale = scale;
            _angle = angle;
            _trajectory = trajectory;
        }

        public int MorphTime {
            get { return _morphTime; }
            set { _morphTime = value; }
        }

        public int LifeTime {
            get { return _lifeTime; }
            set { _lifeTime = value; }
        }

        public Color Color {
            get { return _color; }
            set { _color = value; }
        }

        public double Alpha {
            get { return _alpha; }
            set { _alpha = value; }
        }

        public double Scale {
            get { return _scale; }
            set { _scale = value; }
        }

        public double Angle {
            get { return _angle; }
            set { _angle = value; }
        }

        public IEnumerable<PointF> Trajectory {
            get { return _trajectory; }
            set { _trajectory = value; }
        }

        public ParticleState Clone() {
            return new ParticleState(_morphTime, _lifeTime, _color, _alpha, _scale, _angle, _trajectory);
        }

        public void Change(ParticleState start, ParticleState end, double step) {
            int r = start.Color.R + (int) Math.Round(step * (end.Color.R - start.Color.R));
            int g = start.Color.G + (int) Math.Round(step * (end.Color.G - start.Color.G));
            int b = start.Color.B + (int) Math.Round(step * (end.Color.B - start.Color.B));
            _color = Color.FromArgb(r, g, b);
            _alpha = start.Alpha + step * (end.Alpha - start.Alpha);
            _scale = start.Scale + step * (end.Scale - start.Scale);
            _angle = start.Angle + step * (end.Angle - start.Angle);
        }
    }
}
